package com.agilegroup.crm.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.agilegroup.crm.R;
import com.agilegroup.crm.model.ContactData;

/**
 * @author Hisham
 *
 */
public class ContactAdapter extends BaseAdapter{

	private Context context;
	private List<ContactData> contactData;
	
	public ContactAdapter(Context context, List<ContactData> contactData) {
		this.contactData=contactData;
		this.context=context;
	}
	public int getCount() {
		return contactData.size();
	}

	public Object getItem(int position) {
		return contactData.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
        if (v == null)
        {
           LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           v = vi.inflate(R.layout.lead_row, null);
           
           TextView id = (TextView)v.findViewById(R.id.txtid);
           TextView leadName = (TextView)v.findViewById(R.id.txtleadName);
           TextView leadCompany = (TextView)v.findViewById(R.id.txtleadCompany);
           TextView leadOwner = (TextView)v.findViewById(R.id.txtleadOwner);
           TextView email = (TextView)v.findViewById(R.id.txtEmail);
           TextView mobile = (TextView)v.findViewById(R.id.txtMobile);
           
           ContactData data = new ContactData();
           data=contactData.get(position);
           id.setText(data.getId().toString());
           leadName.setText(data.getfName());
           leadCompany.setText(data.getAccountName());
           leadOwner.setText(data.getMobile());
           email.setText(data.getEmail());
           mobile.setText(data.getMobile());
        }
        return v;
	}

}
